package com.example.firstboot.util;

import lombok.Data;

@Data
public class JsonResult<T> {

    /*封装返回的数据*/
    private T data;
    /*封装返回信息的说明*/
    private String msg;
    /*返回的状态编号*/
    private int code;

    public JsonResult() {
        this.code = 0;
        this.msg = "请求成功";
    }

    public JsonResult(T data) {
        this.data = data;
        this.code=0;
        this.msg = "请求成功";
    }


    /*没有返回值，可以自定义状态码和提示信息*/
    public JsonResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public JsonResult(T data, String msg) {
        this.data=data;
        this.code=0;
        this.msg=msg;
    }
    public JsonResult(T data, int code, String msg) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }
}
